package com.neiquan.weiguan.fragment;

import android.Manifest;
import android.support.v4.app.ActivityCompat;
import android.view.View;

import com.neiquan.weiguan.R;
import com.neiquan.weiguan.adapter.MyBaseAdapter;
import com.neiquan.weiguan.adapter.VideoListAdapter;
import com.neiquan.weiguan.colorful.Colorful;
import com.neiquan.weiguan.colorful.setter.ViewGroupSetter;
import com.neiquan.weiguan.fragment.base.BaseListFragment;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;

/**
 * Created by cxh on 2016/6/2.
 */
public class VideoListFragment extends BaseListFragment {


    @Override
    protected boolean isHaveHead() {
        return true;
    }

    @Override
    protected void setHeadViews() {
        setTitleTv("视屏");
        setBackGone();
        //分享增加权限为了适配新的android 6.0 permission系统,你需要加入requestPermission()方法来获取权限， 详细方法请参照:https://developer.android.com/training/permissions/requesting.html
        String[] mPermissionList = new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CALL_PHONE, Manifest.permission.READ_LOGS, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.SET_DEBUG_APP, Manifest.permission.SYSTEM_ALERT_WINDOW, Manifest.permission.GET_ACCOUNTS};
        ActivityCompat.requestPermissions(getActivity(), mPermissionList, 100);
        setupColorful();
    }

    @Override
    protected void setupColorful() {
        ViewGroupSetter listViewSetter = new ViewGroupSetter(mRecyclerview);
        listViewSetter.childViewBgColor(R.id.rel_videolist_userinfo_item, R.attr.root_view_bg);
        listViewSetter.childViewTextColor(R.id.videolist_item_username, R.attr.text_color);
        listViewSetter.childViewTextColor(R.id.videolist_item_speak_count, R.attr.text_color);
        listViewSetter.childViewTextColor(R.id.videolist_item_text, R.attr.text_color);
        colorful = new Colorful.Builder(this)
                .backgroundColor(R.id.lin_base_list_fragment_title, R.attr.title_bottom_view_bg)
                .backgroundColor(R.id.refesh_ly, R.attr.root_view_bg)
                .setter(listViewSetter)
                .create();
    }

    @Override
    protected MyBaseAdapter getAdapter() {
        return new VideoListAdapter(getActivity(), null);
    }

    @Override
    protected int getLineNum() {
        return 1;
    }

    @Override
    protected void getDateFromWeb() {

    }

    @Override
    public void onRetryClick() {

    }

    @Override
    public View getScrollableView() {
        return null;
    }

    @Override
    public void onPause() {
        super.onPause();
        JCVideoPlayer.releaseAllVideos();
    }
}
